
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace ScrewTurn.Wiki.PluginFramework {

	/// <summary>
	/// Contains a Snippet.
	/// </summary>
	[Serializable]
	public class Snippet {

		private string name, content;
		private IPagesStorageProvider provider;

		/// <summary>
		/// Initializes a new instance of the <b>Snippet</b> class.
		/// </summary>
		/// <param name="name">The Name of the Snippet.</param>
		/// <param name="content">The Content of the Snippet.</param>
		/// <param name="provider">The Provider of the Snippet.</param>
		public Snippet(string name, string content, IPagesStorageProvider provider) {
			this.name = name;
			this.content = content;
			this.provider = provider;
		}

		/// <summary>
		/// Gets the Name of the Snippet.
		/// </summary>
		public string Name {
			get { return name; }
		}

		/// <summary>
		/// Gets or sets the Content of the Snippet.
		/// </summary>
		public string Content {
			get { return content; }
		}

		/// <summary>
		/// Gets the Provider of the Snippet.
		/// </summary>
		public IPagesStorageProvider Provider {
			get { return provider; }
		}

	}

	/// <summary>
	/// Compares two Snippet objects.
	/// </summary>
	public class SnippetNameComparer : IComparer<Snippet> {

		/// <summary>
		/// Compares two Snippets' Names.
		/// </summary>
		/// <param name="x">The first Snippet.</param>
		/// <param name="y">The second Snippet.</param>
		/// <returns>The result of the comparison (1, 0 or -1).</returns>
		public int Compare(Snippet x, Snippet y) {
			return StringComparer.OrdinalIgnoreCase.Compare(x.Name, y.Name);
		}

	}

}
